package com.itany.corejava.day06;

public class People {
    private String name;
    private int age;
    private boolean sex;
    private People partener;

    public People(String name, int age, boolean sex) {
        this.name = name;
        this.age = age;
        this.sex = sex;
    }


    public boolean marry(People partener){

        if(this.sex==partener.sex){
            System.out.println("同性不能结婚");
            return false;
        }

        if(this.partener!=null||partener.partener!=null){
            System.out.println("已经结婚的不能结婚");
            return false;
        }

        this.partener=partener;
        partener.partener=this;
        return true;
    }





    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public boolean isSex() {
        return sex;
    }

    public void setSex(boolean sex) {
        this.sex = sex;
    }

    public People getPartener() {
        return partener;
    }

    public void setPartener(People partener) {
        this.partener = partener;
    }
}
